package com.bgs.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.bgs.pojo.Detailed;
import com.bgs.pojo.Money;
import com.bgs.pojo.Social;
import com.bgs.service.DetailedService;
import com.bgs.service.MoneyService;
import com.bgs.service.SocialService;
import com.bgs.tool.R;
import com.bgs.utils.LocaldatetimeUtils;
import com.bgs.vo.SocialVo;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 社保明细表 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2022-05-08
 */
@CrossOrigin
@RestController
@RequestMapping("/detailed")
public class DetailedController {

    @Autowired
    private DetailedService detailedService;


    @ApiOperation(value = "社保明细列表")
    @GetMapping("/findAll/{sid}")
    public R findAllDetailed( @ApiParam(name = "sid", value = "社保ID", required = true)
                              @PathVariable Integer sid){
        List<Detailed> list1 =  detailedService.findAllDetailed1(sid);//社保明细
        List<Detailed> list2 =  detailedService.findAllDetailed2(sid);//公积金明细
        SocialVo s =detailedService.findByIdSpcialvo(sid);//社保表id

        return R.ok().data("list1",list1).data("list2",list2).data("s",s);
    }


    @ApiOperation(value = "修改社保明细（需要有ID值）")
    @PostMapping("/updateDetailed")
    public R updateMoney(@RequestBody Detailed d){

        boolean flag = detailedService.updateDetailed(d);
        if (flag){
            return R.ok();
        }else {
            return R.error();
        }
    }


}

